<?php
	require_once '../../controller/perfis/' . basename(__FILE__);
	
	$pagina[0] = array('Perfis', '../../view/perfis/pesquisar.php');
	$pagina[1] = array(( $id > 0 ) ? 'Editar Perfil' : 'Inserir Perfil');
	
    require_once '../../template/header.php';
    
?>
<ul class="navmenu">
	<li><a class="voltar" href="pesquisar.php">Voltar</a></li>
    <li><a class="novo" href="cadastrar.php">Novo</a></li>
</ul>
<div id="conteudo">
	<?php TMensagens::exibirStatus( $erro, $sucesso ) ?>
	<form method="post" action="<?php echo basename(__FILE__); if ( $id ) echo '?id=' . $id; ?>" >
        <fieldset>
        	<legend>Perfil</legend>
            <table>       
                <tr>
                    <td>Nome</td>
                    <td><input type="text" name="txtNome" class="textoMedio" value="<?php echo $objeto->nome; ?>" /></td>
                </tr>
                <tr>
                    <td>Comportamento</td>
                    <td>
                    	<select name="ddlPerfilComportamentalID" id="ddlPerfilComportamentalID" class="textoMedio">
                            <?php TSelect::MontaDropDownList(Listas::RetornarPerfisComportamentais(),$objeto->perfilcomportamentalid) ?>
                        </select>
					</td>
                </tr>           
            </table>
		</fieldset>           
<?php 	if ( isset ( $operacoes ) ): $grupo = NULL; ?>
<?php 		foreach ( $operacoes as $o ):  ?>
<?php			if ( $grupo != $o['grupo'] ): $grupo = $o['grupo'] ?>
<?php 				if ( $grupo != $operacoes[0]['grupo'] ): ?>
				</ul>
			</fieldset>
<?php 				endif; ?>
			<fieldset>
				<legend><?php echo $grupo ?></legend>
				<ul>
<?php 			endif; ?>
					<li>
						<input type="checkbox" id="operacao<?php echo $o['operacaoid'] ?>" name="operacao<?php echo $o['operacaoid'] ?>" value="<?php echo $o['operacaoid'] ?>" <?php if ( $o['permissao'] == true ){ echo 'checked="checked"'; } ?>/>
						<label for="operacao<?php echo $o['operacaoid'] ?>"><?php echo $o['nome'] ?></label>
					</li>
<?php 		endforeach; ?>
				</ul>
			</fieldset>
<?php 	endif; ?>
		<p class="botoeira">
        	<input type="submit" name="btnAcao" title="Salvar" value="Salvar" />&nbsp;
			<?php if ( $id ) { echo "<input type=\"submit\" name=\"btnAcao\" title=\"Excluir\" value=\"Excluir\" onclick=\"javascript: return confirm('Deseja realmente excluir o registro?');\" />&nbsp;"; } ?>
        </p>
        <input type="hidden" name="id" value="<?php echo $objeto->perfilid ?>"/>
    </form>
</div>
<?php require_once '../../template/footer.php'; ?>